import { join } from 'lodash-es';
import { omitData } from './common';

/*
 * @Author: liujm
 * @Date: 2022-11-11 18:16:31
 * @Description: 默认参数
 */

class DefaultParam {
  constructor(data, files = [], isSaveFile = true) {
    this.data = data;
    this.files = files;
    this.isSaveFile = isSaveFile;
    this.result = {
      ...data,
      // 节点名称
      taskName: data.nodeName,
      // 密级
      documentSecret: data.secret,
      // 紧急
      documentUrgency: data.urgencys,
      // 主送
      mainSendId: join(data.mainSendId, ','),
      // 抄送
      copySendId: join(data.copySendId, ','),
      documentInfo: JSON.stringify({
        ...omitData(data),
        fileAttachments: isSaveFile ? files.map((t) => ({
          fileId: t.fileId,
          fileName: t.fileName,
          fileSizeString: t.fileSizeString,
          fileSize: t.fileSize,
        })) : data.fileAttachments
      })
    };
  }

  getDefaultParam = () => this.result;
}

export default DefaultParam;
